package org.jkuang.qstar.commons.jni;

import java.util.concurrent.atomic.AtomicInteger;

public class DicMap extends Native {

	private static AtomicInteger seq = new AtomicInteger();
	private int module = seq.getAndIncrement();
	public static void main(String[] args) {
		DicMap map = new DicMap(12);
		map.put("1asdfasdfa");
		System.out.println(map.find(0));
	}

	public DicMap(int part) {
		create(module, part);
	}

	public int put(String key) {
		return put(module, key);
	}

	public void remove(String key) {
		remove(module, key);
	}

	public int get(String key) {
		return get(module, key);
	}

	public String find(int index) {
		return find(module, index);
	}

	public int maxSeq() {
		return maxSeq(module);
	}

	public void destroy() {
		destroy(module);
	}

	@Override
	protected void finalize() throws Throwable {
		// TODO Auto-generated method stub
		super.finalize();
		destroy();
	}

	private native void create(int index, int part);

	private native void destroy(int index);

	private native int get(int index, String key);

	private native void remove(int index, String key);

	private native int put(int index, String key);

	private native String find(int index, int key);

	private native int maxSeq(int index);

}